package com.up4years.dataapi.dao.base;

import org.apache.log4j.Logger;

 
/**
 * 多数据源配置
 * @author xuxingan
 *
 */
public class DBContextHolder {
	
	public static final String READ_DATA_SOURCE = "read_dataSource";
	public static final String WRITE_DATA_SOURCE = "write_dataSource";
	public  static final Logger logger = Logger.getLogger(DBContextHolder.class);
	private static final ThreadLocal<String> contextHolder = new ThreadLocal<String>();
	
	public static void setDBType(String dbType){
 		logger.debug("切换数据源为"+dbType);
		contextHolder.set(dbType);
	}
	
	public static String getDBType(){
 		logger.debug("当前使用的数据源为"+contextHolder.get());
		return contextHolder.get();
	}
	
	public static void clearDBType(){
		contextHolder.remove();
	}
}
